import http from '../../http'
import type { ApiResponse, PageResponse } from '@/types/api'

export interface CommentAdminVO {
  id: number
  articleId: number
  parentId: number
  content: string
  nickname?: string
  email?: string
  status: number
  createTime: string
}

export async function adminPageComments(params: { pageNo: number; pageSize: number; status?: number; articleId?: number }) {
  const resp = await http.get<ApiResponse<PageResponse<CommentAdminVO>>>('/admin/comments', { params })
  return resp.data
}

export async function adminApproveComment(id: number) {
  const resp = await http.put<ApiResponse<boolean>>(`/admin/comments/${id}/approve`)
  return resp.data
}

export async function adminRejectComment(id: number) {
  const resp = await http.put<ApiResponse<boolean>>(`/admin/comments/${id}/reject`)
  return resp.data
}

export async function adminDeleteComment(id: number) {
  const resp = await http.delete<ApiResponse<boolean>>(`/admin/comments/${id}`)
  return resp.data
}


